package com.sskj.trafficcontrol.web.controller;

import com.sskj.trafficcontrol.consts.AppRequestConsts;
import com.sskj.trafficcontrol.consts.ResultJsonUtil;
import com.sskj.trafficcontrol.model.param.LoginParam;
import com.sskj.trafficcontrol.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @author : zhao kuo
 * @date : 2019/1/29 21:55
 * @description :
 */
@RestController
@RequestMapping(value = "/account", produces = AppRequestConsts.CONTENT_TYPE_JSON, method = RequestMethod.POST)
public class AccountController {

    @Autowired
    private AccountService accountService;

    @RequestMapping(value = "/login")
    public String  login(@RequestBody LoginParam loginParam){

        if(accountService.login(loginParam)!=null){
            return ResultJsonUtil.buildSuccessDataJson(accountService.login(loginParam));
        }else{
            return ResultJsonUtil.buildErrorJson("400","账号或者密码错误");
        }

    }

}
